class Solution
{
public:
    bool detectCapitalUse(string word)
    {
        if (word.size() == 1)
        {
            return true;
        }
        bool lower = (word[1] >= 'a' && word[1] <= 'z') || (word[0] >= 'a' && word[0] <= 'z');
        for (int i = 1; i < word.size(); ++i)
        {
            if (word[i] >= 'a' && word[i] <= 'z')
            {
                if (!lower)
                {
                    return false;
                }
            }
            else if (lower)
            {
                return false;
            }
        }
        return true;
    }
};